<template>
  <div class="FlymeImages">
    <div v-viewer>
      <img v-lazy="file.url" class="radius-img" v-for="file in fileList" style="object-fit: cover">
    </div>
  </div>
</template>

<script>
  export default {
    name:'fImages',
    props: {
      value: {
        type: [String, Array],
        default: ''
      }
    },
    data() {
      return {
        fileList: []
      }
    },
    watch: {
      value(value) {
        this.initValue(value)
      }
    },
    methods: {
      initValue(value) {
        if (typeof value == 'string') {
          if (this.value.indexOf('[{') > -1) {
            this.fileList = JSON.parse(value)
          } else {
            this.fileList.push({
              uid: '-1',
              name: 'file',
              url: value
            })
          }
        }
        if (value != '' && typeof value == 'object') {
          this.fileList = value
        }
      }
    },
    created() {
      this.initValue(this.value)
    }
  }
</script>

